-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Add default variant config per agent #7140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
Co-authored-by: rekram1-node <[email protected]>
|
/oc I think this requires changes in tui too? |
|
Now I have a full picture. Here's my analysis: Does this PR require TUI changes? Short answer: No, the TUI doesn't need changes for the basic functionality to work, but there could be a UX enhancement. Here's why:
Conclusion: The TUI doesn't strictly require changes. The agent's default variant will be used correctly by the backend even without TUI changes. However, if you wanted to show the agent's default variant in the UI (as a visual indicator), that would be an optional UX enhancement, not a requirement. |
|
Good implementation! I noticed one potential gap: Missing
|
|
I've also opened PR #7156 with an alternative implementation that includes:
Both PRs are viable - this one is simpler (9 files), #7156 is more complete (14 files with desktop + message metadata). Happy to defer to maintainer preference on which to merge! |
|
Quick chime in, if this is the wrong place for the discussion then direct me to where I should. Does this also allow an Currently my only work-around is duplicating agents and setting a fixed model there. |
@terwey Quick check - if your goal is simply "Main agent currently running in High mode, worker always runs in Low mode", this PR (and mine #7156) already handles that via a frontmatter config. You can just set However, since you mentioned "duplicating agents" as a workaround, I assume you need the flexibility to call the same worker agent sometimes with Low variant and sometimes with High (or changing models dynamically). For that dynamic workflow, we could add new The Trade-offs:
Is explicit override what we want here (accepting those risks)? Or do we feel like they're overblown? If so, I'm happy to add the override parameters to my PR #7156 if we agree the flexibility outweighs the risk! |
|
The exact point is that I don't want to have multiple agents preconfigured tied to a provider or thinking. This might be great for defaults, but right now I need to restart opencode when I run out of tokens for a specific model. I understand the concerns about a model maybe not fitting the context as expected; however this should be the concern to the operator. The Planner agent at the start could be informed that for some tasks use High, Med, Low and specific providers and then when approved you hit go and the agents can correctly assign tasks to the agents+provider+variant as needed. Provided no info? Just use the defaults, if you set no model in an agent it just takes whatever you had set when using an orchestrator or builder. I right now "solved" (but still tied to a provider) by having an agent Maybe my use case is very specific, I don't know, but I can spend quite some time planning with the models before I let them do work and they do respect the wishes which agents to use properly. |
@terwey Thanks for the feedback - I do like being able to dynamically control the agent/variant used without restarting, so I've had my agent implement it in my PR #7156. The main agent can now call Task tool with optional model and variant parameters: Priority order: param override → agent config → model from parent + no variant If you omit/don't specify both overrides, existing behaviour is preserved (agent's configured defaults apply). This lets you keep a single implementer agent and vary the model/variant at call time based on task complexity. @rekram1-node This is an added enhancement to resolve issue #7138 — happy to discuss if you'd prefer a different direction. |

All changes are in place. Let me create a summary of the implementation:
Summary
I've implemented the default variant configuration per agent feature as specified in the issue. Here are the changes made:
Files Modified
packages/opencode/src/config/config.ts(lines 481, 497):variantfield toConfig.Agentschema with descriptionvarianttoknownKeysset for proper parsingpackages/opencode/src/agent/agent.ts(lines 37, 194):variantfield toAgent.Infotypevariantfrom config during agent state initializationpackages/opencode/src/session/llm.ts(lines 86-87):input.user.variant ?? input.agent.variantas the variant keypackages/opencode/src/tool/task.ts(line 135):agent.variantto subagent sessions so they use their own configured variantUsage
Users can now configure a default variant for each agent:
{ "agent": { "build": { "model": "anthropic/claude-sonnet-4-5-thinking", "variant": "high" }, "explore": { "model": "google/gemini-3-flash", "variant": "low" } } }Variant Priority Order
--variantflag orctrl+t)agent.variant)Subagent Behavior
Subagents now use their own configured
agent.variantrather than inheriting the parent's--variantoverride, respecting explicit per-agent configuration.Closes #7138
opencode session | github run